<template>
    <!--UDF/注释-->
    <div id="UdfDetails">
        <g-details :detailData="data.detailData" :inputConfig="inputConfig" :rules="rules" ref="input"></g-details>
    </div>
</template>

<script>
import baseMixin from "@/mixins/BaseMixin";

export default {
    name: "UdfDetails",
    mixins: [baseMixin],
    props: {
        data: {
            type: Object
        }
    },
    data() {
        return {
            inputConfig: [
                    {
                        type: "input",
                        label: "UDF1",
                        props: "susr1",
                    },
                    {
                        type: "input",
                        label: "UDF2",
                        props: "susr2",
                    },
                    {
                        type: "input",
                        label: "UDF3",
                        props: "susr3",
                    },
                    {
                        type: "input",
                        label: "UDF4",
                        props: "susr4",
                    },
                    {
                        type: "input",
                        label: "UDF5",
                        props: "susr5",
                    },
                    {
                        type: "textarea",
                        label: this.$t('common.note'),
                        props: "notes",
                    },
                    /*{
                        type: "input",
                        label: "计费",
                        props: "",
                    },*/
                    {
                        type: "input",
                        label: this.$t('in.cubicmeter'),
                        props: "cubicmeter",
                    },
                    {
                        type: "input",
                        label: this.$t('in.hundredweight'),
                        props: "hundredweight",
                    },
            ],
            rules: {

                cubicmeter: [
                    {validator: this.verify, trigger: 'blur'},
                ],
                hundredweight: [
                    {validator: this.verify, trigger: 'blur'},
                ]
            },
        }
    },
    methods: {
        verify(rule, value, callback) {
            if (value === '') {
                callback();
            } else {
                var re = /[^0-9.]/;
                let te = value;
                let flag = re.test(te)
                if (!flag) {
                    if (value < 0) {
                        this.$message.error(this.$t('app.inputNumberPlease'))
                        this.inputData[rule.field] = ""
                        callback(new Error());
                    } else {
                        callback();
                    }
                } else {
                    this.$message.error(this.$t('app.inputNumberPlease'))
                    this.inputData[rule.field] = ""
                    callback(new Error());
                }
            }
        },
    },
    mounted() {
    },
    watch: {},
}
</script>

<style scoped>

</style>
